home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-17 | 29.1 KB | 737 lines | [TEXT/MPS ] |
- #
- # ****************************************************************************
- #
- # File Name: DoTasks.Lib
- #
- # Contains: xxx put contents here xxx
- #
- # Written by: Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
- #
- # Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
- #
- # ****************************************************************************
- # C h a n g e H i s t o r y (most recent first):
- # ****************************************************************************
- #
- # Vers Date Author Description
- # ---- -------- ------ ---------------------------------------------
- # <1.0.17> 12/6/93 KTA Marked DoCloseApp().
- # <1.0.16> 12/2/93 KTA DOSetupApp() - Changed output when aboutBox not tested, and
- # aligned the header, added gDoSetupAppHook1 and 2 and added
- # gDoCloseAppHook1 and 2. Removed all calls to DoSpecialTest().
- # <1.0.15> 11/19/93 NAGA modify TCS Format
- # <1.0.14> 9/29/93 KTA DoWindow() - Changed one output line to read, 'Scrolling will
- # not be tested in DoWindow().'
- # <1.0.13> 9/22/93 KTA DoSetUpApp() - Bug Fix gSetUpForSaveDoc was accidentally renamed
- # gSetUpForSaveDoc.
- # <1.0.12> 9/13/93 KTA Updated TestLevel specification.
- # <1.0.11> 9/9/93 KTA DoSetUpApp() - Changed output line so it does not say 'About to
- # …'
- # <1.0.10> 8/30/93 KTA Updated task headers and parameters.
- # <1.0.9> 8/25/93 KTA Added support for parity checking the TCS stack.
- # <1.0.8> 7/30/93 KTA DoFiles() - only call revert if ModifyDocument was successful.
- # <1.0.7> 7/19/93 KTA Updates for FindWindow() to handle descriptors.
- # <1.0.6> 7/14/93 KTA International Support: see DoFiles(), DoSetupApp(), and
- # DoCloseApp().
- # <1+> 5/21/93 NAGA Adding header and porting old files to follow new standards
- #
- # ****************************************************************************
- #
-
- ########################################################################
- # External libraries
- #=======================================================================
- Libraries "OutPut.Lib","Font.Lib","StandardFile.Lib","TCS.Lib","Draw.Lib","Print.Lib","LaunchQuit.Lib","Misc.Lib","TargetCheck.Lib", "DA.Lib","UserInterface.Lib";
-
-
- #########################################################################
- # DoDraw( pTestMethod, pSpecifier, pNumTimes )
- #========================================================================
- # Author: Kevin Avoy
- # Description: This task is a high level task which controls the amount and
- # type of draw testing which will be automatically performed (based upon
- # predefined application specific data structures).
- # Parameters: pTestMethod - the method of testing desired.
- # 1 - random object will be generated <pNumtimes> times.
- # 2 - a random object will be generated for all tools
- # defined in the gToolList.
- # pSpecifier - (String, integer, descriptor) window pSpecifier in
- # which drawing will occur.
- # pNumTimes - (integer) number of times to perform the <pTestMethod>.
- # Task references : A number of global undefined task references have been provided
- # to allow scriptwriters the ability to customize calls to DoDraw();
- # gDoDrawHook1 - prior to any drawing.
- # gDoDrawHook2 - after drawing each individual object
- # gDoDrawHook3 - after completion of drawing all objects
- # Returns: Nothing
- # Examples: DoDraw(1,1,1)
- # Assumptions: Data Structures are set up correctly (see the HitchHiker's guide for details)
- # Notes: If the pTestMethod parameter is not explicitly passed in it
- # can be set by defining the global gDrawLevel. gDrawLevel can
- # be an integer or a list. If gDrawLevel is an integer it will be
- # used as the pTestMethod input parameter. If gDrawLevel is a list
- # the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
- #========================================================================
- # History:
- # KTA 7/30/93 Changed name of gSetUpDoDraw -> gDoDrawHook1, changed name of
- # gClearDoDraw -> gDoDrawHook3, Added gDoDrawHook2
- # KTA 8/25/93 Added ability to set gDrawLevel to a list
- #########################################################################
- TASK DoDraw(pTestMethod := -1, pSpecifier := 0, pNumTimes := 1 )
- begin
- global gDrawLevel, gToolList;
-
- if (global gDebugFlag)
- begin
- println "DoDraw() input paramters pTestMethod - {pTestMethod}, pSpecifier - {pSpecifier}, mu,Objects - {pNumTimes}";
- println " gDrawLevel - ", gDrawLevel;
-
- end;
- if (pTestMethod = -1)
- begin
- if (typeOf(gDrawLevel) = 'list')
- begin
- pTestMethod := gDrawLevel[1];
- pNumTimes := gDrawLevel[2];
- end;
- else
- pTestMethod := gDrawLevel;
- end;
-
- if (pTestMethod)
- begin
- if (global gDoDrawHook1)
- call (gDoDrawHook1);
- if (pTestMethod = 1) # Totally Random Object
- begin
- Println "------- DoDraw - pTestMethod (1) ('{pNumTimes}' - Random structure(s)) --------";
- for i := 1 to pNumTimes
- begin
- theObject := {'Random','Random','Random','Random','Random'};
- DrawObject(theObject, pSpecifier);
- If(global gDoDrawHook2)
- call(gDoDrawHook2);
- end;
- end;
- else if (pTestMethod = 2) # Random structure for all tools
- begin
- Println "------- DoDraw - pTestMethod (2) (Random structure for all tools) {pNumTimes} Times--------";
- for i := 1 to pNumTimes
- begin
- for toolNum := 1 to card(gToolList)
- begin
- theObject := {'Random','Random','Random','Random','Random'};
- theTool := gToolList[toolNum];
- # Insert the tool description into the object structure
- # so the object knows how to draw itself
- theObject := InsertElemStruct(theTool, theObject);
- DrawObject(theObject, pSpecifier);
- If(global gDoDrawHook2)
- call(gDoDrawHook2);
- end;
- end;
- end;
- end;
- else
- Println "-------- DoDraw is turned - OFF ---------------";
-
- Println "-----------------------------------------------";
- Println;
- if global gDoDrawHook3
- call (gDoDrawHook3);
- end; # DoDraw()
-
- #########################################################################
- # DoWindow( pTestMethod, pSpecifier, pRestoreWindow, pNumTimes )
- #========================================================================
- # Author: Kevin Avoy
- # Description: This task is a high level task which controls the amount and
- # type of window testing which will be automatically performed.
- # Parameters: pTestMethod - the method of testing desired.
- # 1 - a less complete window test (functionlist build
- # dynamically based on gDoWindowList see below)
- # 2 - complete window test scrolling, sizing, dragging, zooming.
- # pSpecifier - (String, integer, descriptor) window pSpecifier for
- # to be exercised.
- # pRestoreWindow - Boolean - indicates whether or not to restore
- # the window to it's original condition.
- # pNumTimes - (integer) number of times to perform the <pTestMethod>.
- # Returns: Nothing
- # Examples: DoWindow(1,0,0,2)
- # Assumptions:
- # Notes: For more info in what each test does see TestWindow() in
- # 'UserInterface.lib'.
- # If the pTestMethod parameter is not explicitly passed in it
- # can be set by defining the global gWindowLevel. gWindowLevel can
- # be an integer or a list. If gWindowLevel is an integer it will be
- # used as the pTestMethod input parameter. If gWindowLevel is a list
- # the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
- #
- # A global, gDoWindowList, has been provided as a way to indicate
- # which tests are available for a given application.
- # NOTE: This is only valid if pTestWindow evaluates to 2.
- # e.g. global gDoWindowList := {1,1,1,1};
- # Set each element to 1 or 0.
- # Flag for performing DoWindows tests as follows:
- # Element: 1 - Sizing
- # 2 - Scrolling
- # 3 - Dragging
- # 4 - Zooming
- #
- #========================================================================
- # History:
- # KTA 9/29/93 Changed output to read "Scrolling will not be tested in DoWindow()."
- #########################################################################
- TASK DoWindow(pTestMethod := -1, pSpecifier := 0, pRestoreWindow := 0, pNumTimes := 1 )
- begin
- global gWindowLevel, gNoScrollTest, gAppTitle, gDoWindowList;
- if (pTestMethod = -1)
- begin
- if (typeOf(gWindowLevel) = 'list')
- begin
- pTestMethod := gWindowLevel[1];
- pNumTimes := gWindowLevel[2];
- end;
- else
- pTestMethod := gWindowLevel;
- end;
-
- if (pTestMethod)
- begin
- if global gSetupDoWindow
- call (gSetupDoWindow);
-
- if (pTestMethod = 1) ## Quicklook Window Tests
- begin
- if gDoWindowList
- begin
- Println "------- DoWindow - pTestMethod (1) - (Quicklook Window Test) {pNumTimes} times --------";
- WindowFunctionList := {}; # initialize list
- # build list dynamically based on gDoWindowList
- if gDoWindowList[1]
- begin
- WindowFunctionList := insert (2,1,WindowFunctionList); # insert 2 in position 1
- WindowFunctionList := insert (1,2,WindowFunctionList); # insert 1 in position 2
- end;
- else
- logstr('Sizing Windows not tested in DoWindow().');
-
- if gDoWindowList[2]
- begin
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (3,NextPos,WindowFunctionList); # insert 3 in next position
- NextPos := (card(WindowFunctionList) + 1);;
- WindowFunctionList := insert (7,NextPos,WindowFunctionList); # insert 7 in next position
- end;
- else
- logstr("Scrolling will not be tested in DoWindow().");
-
- if gDoWindowList[1]
- begin
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (13,NextPos,WindowFunctionList); # insert 13 in next position
- end;
-
- if gDoWindowList[3]
- begin
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (14,NextPos,WindowFunctionList); # insert 14 in next position
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (15,NextPos,WindowFunctionList); # insert 15 in next position
- end;
- else
- logstr('Dragging Windows not tested in DoWindow().');
-
- if gDoWindowList[4]
- begin
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (17,NextPos,WindowFunctionList); # insert 17 in next position
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (17,NextPos,WindowFunctionList); # insert 17 in next position
- end;
- else
- logstr('Zooming Windows not tested in DoWindow().');
-
- if gDoWindowList[1]
- begin
- NextPos := (card(WindowFunctionList) + 1);
- WindowFunctionList := insert (11,NextPos,WindowFunctionList); # insert 11 in next position
- end;
-
- TestWindow(pSpecifier,WindowFunctionList,pRestoreWindow,pNumTimes);
-
- end; # if gDoWindowList
- else # if not gDoWindowList
- logstr('No global gDoWindowList defined so DoWindow() testing not done.');
-
- end; # if (pTestMethod = 2)
- else if (pTestMethod = 2) ## Complete Window Test
- begin
- Println "------- DoWindow - pTestMethod (2) - (Complete Window Test) {pNumTimes} times--------";
- TestWindow(pSpecifier,0, pRestoreWindow,pNumTimes); # Performs functions 1 through 17
- end; # if (pTestMethod = 1)
-
-
- else if(TypeOf(pTestMethod) = 'list') ## Pass in your own Window test (see WindowTest() in the Window.Lib
- begin
- Println "------- DoWindow - pTestMethod 'list' - (Pass in your own) --------";
- TestWindow(pSpecifier, pTestMethod, pRestoreWindow, pNumTimes);
- end;
- end;
- else
- Println "-------- DoWindow is turned - OFF ---------------";
-
- Println "-----------------------------------------------";
- Println;
- end; # DoWindow()
-
-
- #########################################################################
- # DoText(pTestMethod, pNumTimes)
- #========================================================================
- # Author: KTA
- # Description: This task is a high level task which controls the amount and
- # type of font testing which will be automatically performed.
- # Parameters: pTestMethod - the method of testing desired.
- # 1 - Random font test
- # 2 - QuickLook font test
- # 3 - WaterFall font test
- # pNumTimes - (integer) number of times to perform the <pTestMethod>.
- # (not valid for WaterFall testing)
- # Returns: nada
- # Examples: DoText(2,3);
- # Assumptions: global gFontList, gFontSizeList, gFontStyleList must be defined.
- # Notes: If the pTestMethod parameter is not explicitly passed in it
- # can be set by defining the global gFontLevel. gFontLevel can
- # be an integer or a list. If gFontLevel is an integer it will be
- # used as the pTestMethod input parameter. If gFontLevel is a list
- # the 1st element is the pTestMethod, the 2nd is the pNumTimes parameter.
- #========================================================================
- # History:
- #
- #########################################################################
- TASK DoText(pTestMethod := -1, pNumTimes := 1)
- begin
- returnVal := 0;
-
- if not(global gSetFont) #Auto Initilize if not done
- InitFonts();
- global kQLFontTest,gFontLevel,gFontList, gFontSizeList,
- gFontStyleList,gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu,gtextStr,gFontObject;
- if (pTestMethod = -1)
- begin
- if (typeOf(gFontLevel) = 'list')
- begin
- pTestMethod := gFontLevel[1];
- pNumTimes := gFontLevel[2];
- end;
- else
- pTestMethod := gFontLevel; # Set pTestMethod to global gFontLevel
- end;
- Println "The gFontList := ", gFontList;
- Println "The gFontSizeList := ", gFontSizeList;
- Println "The gFontStyleList := ", gFontStyleList;
-
- if (pTestMethod)
- begin
- if global gSetupDoText
- call (gSetupDoText);
- if (pTestMethod = 1) # Random font testing
- begin
- Println "------- DoText - pTestMethod (1) ∂({pNumTimes}∂) random (with global gFontLists) --------";
- for numRecords := 1 to pNumTimes # Type random font records <gNumRandom> times
- begin
- gFontObject := gFontObject + 1; # Increment the object number for TCS info
- RandomRecord := RandomFontRecords();
- FontRecord := SetFontParams(RandomRecord,,gFontObject);
- if(FontRecord)
- begin
- TypeStr("{gtextStr} ");
- ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject); # Match and report back what is actually selected
- Println "• - ",FontRecord;
- returnVal := FontRecord;
- end;
- else
- Println "NOTE: Couldn't complete FontRecord • - ", RandomRecord;
- end;
- end;
- else if (pTestMethod = 2) # Quicklook font testing
- begin # 1 random record for each font
- Println "------- DoText - pTestMethod (2) - 1 record for each font in global gFontLists {pNumTimes} times--------";
- for i := 1 to pNumTimes
- begin
- for each FontItem in gFontList
- begin
- gFontObject := gFontObject + 1; # Increment the object number for TCS info
- RandomRecord := RandomFontRecords({FontItem,"",""});
- FontRecord := SetFontParams(RandomRecord,,gFontObject);
- if(FontRecord)
- begin
- TypeStr("{gtextStr} ");
- ReportSelectedMenuItems({gCurrFontMenu,gCurrSizeMenu,gCurrStyleMenu},gFontObject); # Match and report back what is actually selected
- Println "• - ",FontRecord;
- returnVal := FontRecord;
- end;
- else
- Println "NOTE: Couldn't complete FontRecord • - ", RandomRecord;
- end;
- end;
- end;
- else if (pTestMethod = 3) # WaterFall font testing
- begin
- Println "------- DoText - pTestMethod (3) - WaterFall (with global gFontLists) --------";
- WaterFallFontTest();
- returnVal := 1;
- end;
- end;
- Else
- Println "-------- DoText is turned - OFF ---------------";
- Println "-----------------------------------------------";
- Println;
- if global gClearDoText
- call (gClearDoText);
- Return(ReturnVal);
- end; # DoText()
-
- #########################################################################
- # DoFiles(pTestMethod, pFileName, pSaveAsFlag, pSelectOpen, pRevertMI )
- #========================================================================
- # Author: KTA
- # Description: This task is a high level task which controls the amount and
- # type of file testing which will be automatically performed.
- # Parameters: pTestMethod - Method of testing
- # 1 - All tests outlined below
- # 2 - Save As/Replace, close, open.
- # 3 - Save As/Cancel, Save, modify, revert.
- # 4 - Save/Cancel,Save(unique), Save (same file name)/Replace,
- # Save (same file name)/create unique extension.
- # 5 - Save As/Cancel, Save
- # pFileName - File name to use when saving file if none passed
- # a filename will be generated bassed on the
- # applications name and the time.
- # pSaveAsFlag - Valid for all Testmethods. Indicates whether
- # selecting the Save As menuItem is necessary.
- # 1 - select Save As. HardCoded 'Save As'.
- # 0 - Do not select SaveAs.
- # list - list containing ordinality of 'Save As' menuItem.
- # This parameter has been updated for international support.
- # Now it can also be a list which contains the ordinality of
- # the Save As menuItem. If a it is a list then the Save As menuItem
- # will be selected using the contents of the list.
- # e.g. if pSaveAsFlag = {6,2}, the sixth menuitem from the 2nd menu will
- # be selected as the Save As menuItem.
- # pSelectOpen - Only valid if <pTestMethod> evaluates to 2
- # 0 - Don't select 'Open' or anything else
- # 1 - Select 'Open' - hard coded
- # 2 - Select 'Open' by way of keyboard equivelant 'o'.
- # list - list containing ordinality of 'Open' menuItem.
- # pRevertMI - Only valid if <pTestMethod> evaluates to 3
- # '' - Hard coded 'Revert' menuItem will be selected
- # list - list containing ordinality of revert MenuItem
- # Returns: nada
- # Examples: DoFiles(2, "myFile", {6,2}, {4,2}); # Save, close, open.
- # Assumptions:
- #========================================================================
- # History:
- # KTA 7/7/93 Added pSaveAsFlag to specify the SaveAs menuItem for SaveAs() - intl
- # Added pSelectOpen to specify the Open menuItem for OpenFile() - intl
- # Added pRevertMI to specify the Revert menuItem for Revert() - intl
- # KTA 7/30/93 Only call revert if ModifyDocument was successful
- #########################################################################
- TASK DoFiles(pTestMethod := -1,pFileName := "",pSaveAsFlag := 1, pSelectOpen := 2, pRevertMI := '')
- begin
- global gLastSavedFile;
-
- if (pTestMethod)
- begin
- if (pTestMethod = 1) # All File tests
- begin
- Println "------- DoFiles - testMethod (1) - (All File tests) --------";
- for i := 2 to 4
- DoFiles(i);
- end;
- else if (pTestMethod = 2) # SaveFile, close it, open it.
- begin
- Println "------- DoFiles - testMethod (2) - (Save As/Replace, close it, open it) --------";
- if (SaveAs(pFileName,1,pSaveAsFlag) = 1) # if file saved, but no replace exist
- SaveAs(pFileName,1,pSaveAsFlag); # Save as again, insures replace exist
- CloseWindow(,,0);
- OpenFile(gLastSavedFile,pSelectOpen);
- end;
- else if (pTestMethod = 3) # SaveFile, modify it, revert it.
- begin
- Println "------- DoFiles - testMethod (3) - (Save As/Cancel, Save file, modify it, revert it) --------";
- CancelStandardFile(1,pSaveAsFlag); # SaveAs/Cancel SelectButton('Cancel');
- Save();
- if(ModifyDocument())
- Revert(pRevertMI);
- end;
- else if (pTestMethod = 4) # Save/Cancel, Save - uniqueName, SaveSameName-OverWrite, SaveSameName-AddExtension for unique
- begin
- Println "------- DoFiles - testMethod (4) - (Save/Cancel, Save - uniqueName, SaveSameName-OverWrite, SaveSameName-AddExtension for unique) --------";
- CancelStandardFile(,pSaveAsFlag); # SaveAs/Cancel keyEq('.');
- SaveAs(,0, pSaveAsFlag); ## Save - uniqueName
- SaveAs(gLastSavedFile,1, pSaveAsFlag); ## SaveSameName-OverWrite
- SaveAs(gLastSavedFile,0, pSaveAsFlag); ## SaveSameName-AddExtension for unique
- end;
- else if (pTestMethod = 5) # SaveFile, modify it, revert it.
- begin
- Println "------- DoFiles - testMethod (5) - (Save As/Cancel, Save file) --------";
- CancelStandardFile(1,pSaveAsFlag); # SaveAs/Cancel SelectButton('Cancel');
- Save();
- end;
- end;
- else
- Println "-------- DoFiles is turned - OFF ---------------";
- Println "-----------------------------------------------";
- Println;
- end;
-
- #########################################################################
- # DoSetUpApp(pDismissOpeningDialog, pDefaultWindowSpec, pNewDocPath,
- # pDismissNewDocDialog,pScrapText, pScrapPict, pSaveDoc, pOpenDoc)
- #=======================================================================
- # Author: ML
- #
- # Description: Sets up app after launch. Matches app, closes default
- # window, creates a new document, optionally pastes from scrap,
- # saves document.
- #
- # Parameters: pDismissOpeningDialog - 0 No opening dialog
- # 1 type return key
- # 'string' select button named {string}
- # pDefaultWindowSpec - if -1, no default window - don't close
- # if 0, close first document window
- # if string, then it holds title of window
- # if integer > 0, then it holds ordinality of window
- # Descriptor - window descriptor
- # pNewDocPath - 0 don't create new doc
- # {list} - containing ordinality of 'New' menuItem
- #
- # pDismissNewDocDialog - 0 No new doc dialog
- # 1 type return key
- # 'string' select button named {string}
- # pScrapText - 0 Don't call Scrapbook(global ScrapText)
- # 1 call Scrapbook(global ScrapText)
- # pScrapPict - 0 Don't call Scrapbook(global ScrapPict)
- # 1 call Scrapbook(global ScrapPict)
- # pSaveDoc - 0 Don't save newly created doc via DoFiles(2)
- # 1 Save newly created doc via DoFiles(2)
- # {list} - containing ordinality of Save As menuItem
- # pOpenDoc - 0 Don't save select 'Open' menuitem
- # 1 Select 'open' menuItem - hardcoded
- # 2 - keyEq('o');
- # {list} - containing ordinality of 'Open' menuItem
- #
- # Task references : A number of global undefined task references have been provided
- # to allow scriptwriters the ability to customize calls to DoSetUpApp();
- # gCustomScrapText - instead of generic Scrapbook(kScrapTEXT)
- # gCustomScrapPict - instead of generic Scrapbook(kScrapPICT)
- # gSetUpForSaveDoc - To do any setup before calling DoFiles(2)
- # Returns: None
- #
- # Example: DoSetUpApp(0,1,{'New','File'},0,0,0,1)
- #=======================================================================
- # History:
- # KTA 7/7/93 Added pOpenDoc parameter to pass the Open menuItem to OpenFile if needed (intl)
- # Slightly modified pNewDocPath (intl)
- # KTA 7/19/93 changed specifier so descriptor is not embedded in a list.
- # KTA 8/24/93 TCS Stack parity check
- # KTA 9/9/93 Changed output line so it does not say 'About to …'
- # KTA 12/1/93 Deleted call to DoSpecialTest() and added hooks gDoSetUpAppHook1,
- # gDoSetUpAppHook2
- #########################################################################
- TASK DoSetUpApp(pDismissOpeningDialog:=0, pDefaultWindowSpec:=0, pNewDocPath:={'New','File'},
- pDismissNewDocDialog:=0,pScrapText:=0, pScrapPict:=0, pSaveDoc:=1, pOpenDoc := 2)
- begin
- If (global gDoSetUpAppHook1)
- call (gDoSetUpAppHook1);
- global gFileName,gApptitle,gSetUpScrapText,gSetUpScrapPict;
- LogStr("The expected application is '{gAppTitle}'.");
- MatchApplication(0);
-
- if (pDismissOpeningDialog)
- begin
- if (global gCustomOpeningDialog) # if custom Opening dialog
- Specifier := gCustomOpeningDialog; # define global for DismissDialog
- else
- Specifier := [window o:1 s:dialog];
- if (findWindow(Specifier)) # no opening dialog if twitched to
- begin
- LogStr('Dismissing opening dialog');
- TCSStart({ 1, global kTCSetAppSetup },"Dismiss opening dialog");
- TCSEnd({ 1, global kTCSetAppSetup },DismissDialog(pDismissOpeningDialog,Specifier));
- end;
- end;
-
- If (global gDoSetUpAppHook2)
- call (gDoSetUpAppHook2);
-
- if (pDefaultWindowSpec >= 0 or TypeOf(pDefaultWindowSpec) = 'string'
- or TypeOf(pDefaultWindowSpec) = 'descriptor')
- begin
-
- if match [window o:1]!
- begin
-
- if (pDefaultWindowSpec = 0)
- begin
- if findwindow(0)
- CloseWindow();
- end;
- else
- if FindWindow(pDefaultWindowSpec)
- CloseWindow(,,pDefaultWindowSpec);
-
- end; # if match [window o:1]!
- end; # if (pDefaultWindowSpec >= 0 or TypeOf(pDefaultWindowSpec) = 'string')
-
- if (pNewDocPath)
- begin
- TCSStart({ 1, global kTCSetNewDoc },"Select File - New...");
- TCSEnd({ 1, global kTCSetNewDoc },SelectMenuItem(pNewDocPath[1], pNewDocPath[2])); # Open a New Document
- end;
-
- if (pDismissNewDocDialog)
- begin
- if (global gCustomNewDocDialog) # if custom Opening dialog
- Specifier := gCustomNewDocDialog; # define global for DismissDialog
- else
- Specifier := [window o:1 s:dialog];
- if (findWindow(Specifier)) # no opening dialog if twitched to
- begin
- logstr('Dismissing new document dialog');
- TCSStart({ 2, global kTCSetAppSetup },"Dismiss new document dialog");
- TCSEnd({ 2, global kTCSetAppSetup }, DismissDialog(pDismissNewDocDialog, Specifier));
- end;
- end;
-
- if (pScrapText)
- begin
- if global gCustomScrapText # hook for custom scrap text
- call (gCustomScrapText);
- else
- begin
- Scrapbook(global kScrapTEXT); # Paste TEXT from Scrapbook
- #SpecialKey(returnKey , "Return Key");
- end;
- end; # if (pScrapText)
-
- if (pScrapPict)
- begin
- if global gCustomScrapPict # hook for custom scrap pict
- call (gCustomScrapPict);
- else
- Scrapbook(global kscrapPict);
- end; # if (pScrapPict)
-
- if (global gSetUpForSaveDoc) # hook to setup for Saving Document
- call (gSetUpForSaveDoc);
-
- if (pSaveDoc)
- DoFiles(2,gFileName, pSaveDoc, pOpenDoc);
-
- end; # DoSetUpApp()
-
- #########################################################################
- # DoCloseApp(pSaveRevert, pDismissAboutBox, pPageSetup, pPrinter, pQuit)
- #=======================================================================
- # Author: ML
- # Description: Performs either DoFiles(3) or Dofiles(5), Selects and dismisses
- # the 'About' box, Selects and dismisses 'Page Setup', Selects and
- # dismisses 'Print', thenpQuits.
- # Parameters: pSaveRevert - 0 - Save As/Cancel/Save, no modify/revert
- # 1 - Save As/Cancel/Save, modify/revert
- # -1 - no Save As/Cancel/Save, no modify/revert
- # {list} - International - two elements
- # 1st element
- # list - list containing ordinality of 'Revert' menuItem.
- # integer - Any of the pSaveRevert options listed above.
- # 2nd Element - should be set even if 1st element is 0
- # list - list containing ordinality of 'Save As' menuItem.
- # pDismissAboutBox - -1 - Don't do About Box test
- # 0 - Return key
- # integer > 0 - Click in center of
- # screen {integer} times
- # String - Select button named <string>
- # pPageSetup -
- # 0 - Don't do default PageSetup()
- # 1 - Do default PageSetup()
- # list - list containing ordinality of 'Page Setup' menuItem.
- # pPrinter -
- # 0 - Don't do default Printer()
- # 1 - Do default Printer()
- # list - list containing ordinality of 'Print' menuItem.
- # pQuit -
- # 0 - Don't call Quit() Task
- # 1 - Select 'Quit' - hard coded
- # 2 - KeyEq('q');
- # Returns: None
- #
- # Example: DoCloseApp(1,2)
- #=======================================================================
- # History:
- # KTA 7/14/93 International support: can pass in pSaveRevert as a list of
- # menuitems for saveAs and Revert. Also for pPageSetup, and pPrinter
- # KTA 9/10/93 AboutBox was not being called if pDismissAboutBox was a string
- # KTA 12/1/93 Generic output line "About Box is not being tested" (bug 1121688)
- # KTA 12/1/93 Deleted call to DoSpecialTest() and added hooks gDoCloseAppHook1,
- # gDoCloseAppHook2, gDoCloseAppHook3
- #########################################################################
- TASK DoCloseApp(pSaveRevert := 0, pDismissAboutBox := 0, pPageSetup := 1, pPrinter := 1, pQuit := 1)
- begin
- global gFileName, gApptitle;
- RevertMI := '';
- SaveAsMenu := 1;
-
- If (global gDoCloseAppHook1)
- call (gDoCloseAppHook1);
-
- if(TypeOf(pSaveRevert) = 'list')
- begin
- SaveAsMenu := pSaveRevert[2];
- if(TypeOf(pSaveRevert[1]) = 'list')
- begin
- RevertMI := pSaveRevert[1]; # Set RevertMI to the menuItem was passed in.
- pSaveRevert:= 1; # if a menuItem was passed in Revert must be true
- end;
- else
- pSaveRevert := pSaveRevert[1];
- end;
-
- if (pSaveRevert > 0) # if app supports revert
- DoFiles(3,,SaveAsMenu,,RevertMI); # save as/Cancel, save, modify, revert
- else if (pSaveRevert = 0) # else if 0, no revert
- begin
- logstr("There is no revert in '{gApptitle}'");
- DoFiles(5,,SaveAsMenu); # save as/Cancel, save
- end; # if pSaveRevert < 0, do nothing
-
- if not(pDismissAboutBox = -1) # test about box
- AboutBox(pDismissAboutBox);
- else
- logstr("About Box is not being tested");
-
- if (TypeOf(pPageSetup) = 'list') # Support for (intl)
- PageSetup(, pPageSetup); # Page Setup Testing
- else if (pPageSetup)
- PageSetup(); # Page Setup Testing
-
- if (TypeOf(pPrinter) = 'list') # Support for (intl)
- Printer(pPrinter); # Print Testing
- else if (pPrinter)
- Printer(); # Print Testing
-
-
- If (global gDoCloseAppHook2)
- call (gDoCloseAppHook2);
-
- if not (pSaveRevert < 0) # if haven't done any save above
- SaveAs(gFileName,0,SaveAsMenu); # Save as, new file
-
- if (pQuit)
- Quit(,,pQuit); # Quit
-
- If (global gDoCloseAppHook3)
- call (gDoCloseAppHook3);
- end;